import {request} from 'umi';
import {getApiPrefix, paramsChange} from "@/assets/utils/utils";
import {modulesUrl} from "@/assets/constant/modulesUrl";
import {DemandDetails} from "@/pages/demand/DemandList/data";

/**
 * 发布需求
 * @param id
 */
export async function flow(params: DemandDetails) {
  return request(getApiPrefix(modulesUrl.demandDemand) + "/flow", {
    method: 'POST',
    data: {
      ...paramsChange(params),
      method: 'post',
    },
  });
}

/**
 * 开始并直接到待审核
 * @param id
 */
export async function startAndIssue(id?: string) {
  return request(getApiPrefix(modulesUrl.demandDemand) + "/startAndIssue", {
    params: {
      id: id,
    },
  });
}

/**
 * 获取流程流转可选用户select形式
 * @param id
 */
export async function findCanFlowUserList(id?: string) {
  return request(getApiPrefix(modulesUrl.demandDemand) + "/findCanFlowUserList", {
    params:{
      id:id
    }
  });
}

/**
 * 获取详情列表
 * @param id
 */
export async function detailsList(demandId: string) {
  return request(getApiPrefix(modulesUrl.demandDemand) + "/detailsList", {
    method: 'POST',
    data: {
      demand:{
        id:demandId
      },
      method: 'post',
    },
  });
}

/**
 * 获取附件列表
 * @param id
 */
export async function annexList(demandId: string) {
  return request(getApiPrefix(modulesUrl.demandDemand) + "/annexList", {
    params: {
      id:demandId
    },
  });
}
/**
 * 添加附件
 * @param id
 */
export async function saveAnnex(demandId?: string, annexId?: string) {
  return request(getApiPrefix(modulesUrl.demandDemand) + "/saveAnnex", {
    params: {
      id:demandId,
      annexId:annexId
    },
  });
}

/**
 * 删除附件
 * @param id
 */
export async function deleteAnnexByIds(demandId?: string, annexIds?: string) {
  return request(getApiPrefix(modulesUrl.demandDemand) + "/deleteAnnexByIds", {
    params: {
      id:demandId,
      annexIds:annexIds
    },
  });
}


